// 发票管理

import { FileListType } from '@renderer/types/global'
import axios from 'axios'
const modelUrl = '/finance'
// 进项发票
export interface InvoiceReq {
  invoiceId?: string
  invoiceCode: string
  customerId?: string
  supplierId?: string
  invoiceDate: string
  invoiceAmt: number
  invoiceStatus: number
  invoiceType: number
  remark: string
  detailList: InvoiceResItemDetailList[]
  fileList: FileListType[]
}
export interface InvoiceRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: InvoiceResItem[]
}
export interface InvoiceResItemDetailList {
  purchaseOrderId: string
  purchaseOrderCode: string
  deliveryOrderId: string
  deliveryOrderCode: string
  deliveryDate: string
  purchaseDate: string
  productName: string
  amt: number
}
export interface InvoiceResItem {
  invoiceId: string
  invoiceCode: string
  customerId: string
  customerName?: string
  supplierName?: string
  invoiceDate: string
  invoiceAmt: number
  invoiceStatus: number
  remark: string
  detailList: InvoiceResItemDetailList[]
  index?: number // 导出的序号
  fileList: FileListType[]
  invoiceType: number
}
export interface InvoiceListSearch {
  supplierName?: string
  customerName?: string
  invoiceStartDate: string
  invoiceEndDate: string
  deliveryOrderId: string
  createdStartDate: string
  createdEndDate: string
  invoiceType: number
  invoiceDate: string[]
  createTime: string[]
}

export function editInvoice(data: InvoiceReq) {
  return axios.post<InvoiceRes>(modelUrl + '/invoiceAdit', data)
}

export function delInvoice(data: { invoiceId: string }) {
  return axios.post<object>(modelUrl + '/invoiceDel', data)
}

export function getInvoiceDetail(data: { invoiceId: string }) {
  return axios.post<InvoiceResItem>(modelUrl + '/invoiceDetail', data)
}

export function getInvoiceAllList(data?: InvoiceListSearch) {
  return axios.post<InvoiceRes>(modelUrl + '/invoiceList', data)
}

export function getInvoicePageList(data: InvoiceListSearch) {
  return axios.post<InvoiceRes>(modelUrl + '/invoicePage', data)
}
// 开出发票
// export interface OutInvoiceReq {
//   customerId?: string
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
// }
// export interface OutInvoiceRes {
//   currentPage?: number
//   pageSize?: number
//   totalPage?: number
//   totalCount?: number
//   list: OutInvoiceResItem[]
// }
// export interface OutInvoiceResItem {
//   customerId: string
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
//   createdDt: string
//   createdBy: string
//   updatedBy: string
//   updatedDt: string
//   detailList: []
// }
// export interface OutInvoiceListSearch {
//   customerName?: string
//   taxNo?: string
//   contactName?: string
//   createTime: string[]
// }

// export function editOutInvoice(data: OutInvoiceReq) {
//   return axios.post<OutInvoiceRes>(modelUrl + '/erpOutInvoiceAdit', data)
// }

// export function delOutInvoice(data: { customerId: string }) {
//   return axios.post<object>(modelUrl + '/erpOutInvoiceDel', data)
// }

// export function getOutInvoiceDetail(data: { customerId: string }) {
//   return axios.post<OutInvoiceRes>(modelUrl + '/erpOutInvoiceDetail', data)
// }

// export function getOutInvoiceAllList(data?: OutInvoiceListSearch) {
//   return axios.post<OutInvoiceRes>(modelUrl + '/erpOutInvoiceList', data)
// }

// export function getOutInvoicePageList(data: OutInvoiceListSearch) {
//   return axios.post<OutInvoiceRes>(modelUrl + '/erpOutInvoicePage', data)
// }
